<?php

namespace Home\Controller;

class ScoreController extends CommonController {

    //判断患者是否有积分发起会话
    public function checkScore() {
        //个人信息
        $userInfo = M('User')->where(array('phone' => I('post.sender')))->find();
        if (empty($userInfo) || ($userInfo['type'] == '2' && $userInfo['score'] < 5)) {
            $this->ajaxReturn('no');
        }
    }

    //患者发起会话
    public function addChat() {
        //个人信息
        $userInfo = M('User')->where(array('phone' => I('post.sender')))->find();
        if (!empty($userInfo) && $userInfo['type'] == '2') {
            D('Score')->addChat($userInfo['id'],I('post.receiver'));
        }
    }

}
